package com.isoftstone.securityframework.device.auth.filter;

import java.util.Map;

import com.isoftstone.securityframework.auth.DefaultHttpAuthInitFilter;
import com.isoftstone.securityframework.device.local.DeviceAuthRealm;
import com.isoftstone.securityframework.local.PermissionManagerLocalImpl;

public class DeviceHttpInitFilter extends DefaultHttpAuthInitFilter {


    public static final String CONFIG_INIT_PARAM_NAME = "config";
	/**
	 * 获取web.xml中的Shiro配置
	 */
	@Override
	protected String getShiroConfig() {
        String config = getInitParam(CONFIG_INIT_PARAM_NAME);
        if (config != null) {
        	return config;
        }
        return null;
	}


    /**
     * OSGI环境下需要重写该方法。
     * 由于框架结构，及模块之间的依赖关系，ClassLoader不在父类中提供，由依赖方提供(web依赖local)
     */
    @Override
    protected Map<String, ClassLoader> buildRealmClassLoaders(Map<String, ClassLoader> loaders){
    	loaders = super.buildRealmClassLoaders(loaders);
		loaders.put("realmA", DeviceAuthRealm.class.getClassLoader());
		loaders.put("authc", DeviceFilter.class.getClassLoader());
		loaders.put("permissionRealm", PermissionManagerLocalImpl.class.getClassLoader());
		return loaders;
    }

}
